Using a Web service provided by the WcfService1 project (under Web folder), gets and displays a value of an OPC item.
The main program:
// WcfClient1: Using a Web service provided by the WcfService1 project (under Web folder), gets and displays a value of // an OPC item. // // Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . using System; namespace WcfClient1 { class Program { static void Main() { var client = new Service1Client(); // Use the 'client' variable to call operations on the service. // The following call may throw an exception in case of an error. Production-quality code should catch and // handle the exceptions appropriately. string data = client.GetData(); Console.WriteLine(data); Console.ReadLine(); // Always close the client. client.Close(); } } }
' WcfClient1: Using a Web service provided by the WcfService1 project (under Web folder), gets and displays a value of ' an OPC item. ' ' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . Friend Class Program Shared Sub Main() Dim client = New Service1Client() ' Use the 'client' variable to call operations on the service. ' The following call may throw an exception in case of an error. Production-quality code should catch and ' handle the exceptions appropriately. Dim data As String = client.GetData() Console.WriteLine(data) Console.ReadLine() ' Always close the client. client.Close() End Sub End Class
The Service1 class:
//------------------------------------------------------------------------------ // <auto-generated> // This code was generated by a tool. // Runtime Version:2.0.50727.5456 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // </auto-generated> //------------------------------------------------------------------------------ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] [System.ServiceModel.ServiceContractAttribute(ConfigurationName="IService1")] public interface IService1 { [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IService1/GetData", ReplyAction="http://tempuri.org/IService1/GetDataResponse")] string GetData(); } [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] public interface IService1Channel : IService1, System.ServiceModel.IClientChannel { } [System.Diagnostics.DebuggerStepThroughAttribute()] [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] public partial class Service1Client : System.ServiceModel.ClientBase<IService1>, IService1 { public Service1Client() { } public Service1Client(string endpointConfigurationName) : base(endpointConfigurationName) { } public Service1Client(string endpointConfigurationName, string remoteAddress) : base(endpointConfigurationName, remoteAddress) { } public Service1Client(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : base(endpointConfigurationName, remoteAddress) { } public Service1Client(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : base(binding, remoteAddress) { } public string GetData() { return base.Channel.GetData(); } }
'------------------------------------------------------------------------------ ' <auto-generated> ' This code was generated by a tool. ' Runtime Version:2.0.50727.5456 ' ' Changes to this file may cause incorrect behavior and will be lost if ' the code is regenerated. ' </auto-generated> '------------------------------------------------------------------------------ <System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0"), System.ServiceModel.ServiceContractAttribute(ConfigurationName:="IService1")> _ Public Interface IService1 <System.ServiceModel.OperationContractAttribute(Action:="http://tempuri.org/IService1/GetData", ReplyAction:="http://tempuri.org/IService1/GetDataResponse")> _ Function GetData() As String End Interface <System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")> _ Public Interface IService1Channel Inherits IService1, System.ServiceModel.IClientChannel End Interface <System.Diagnostics.DebuggerStepThroughAttribute(), System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")> _ Partial Public Class Service1Client Inherits System.ServiceModel.ClientBase(Of IService1) Implements IService1 Public Sub New() End Sub Public Sub New(ByVal endpointConfigurationName As String) MyBase.New(endpointConfigurationName) End Sub Public Sub New(ByVal endpointConfigurationName As String, ByVal remoteAddress As String) MyBase.New(endpointConfigurationName, remoteAddress) End Sub Public Sub New(ByVal endpointConfigurationName As String, ByVal remoteAddress As System.ServiceModel.EndpointAddress) MyBase.New(endpointConfigurationName, remoteAddress) End Sub Public Sub New(ByVal binding As System.ServiceModel.Channels.Binding, ByVal remoteAddress As System.ServiceModel.EndpointAddress) MyBase.New(binding, remoteAddress) End Sub Public Function GetData() As String Implements IService1.GetData Return MyBase.Channel.GetData() End Function End Class
Copyright © 2004-2024 CODE Consulting and Development, s.r.o., Plzen. All rights reserved. Web page: www.opclabs.com
Send Documentation Feedback. Resources: Knowledge Base, Product Downloads. Technical support: Online Forums, FAQ.Missing some example? Ask us for it on our Online Forums! You do not have to own a commercial license in order to use Online Forums, and we reply to every post.